package com.Cychat.schedule.service.impl;

import com.Cychat.commons.entity.pojo.PetOwner;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.Cychat.schedule.mapper.PetOwnerMapper;
import com.Cychat.schedule.service.PetOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Auther: 谢宝辉  <br/>
 * Date: 2025/10/28:20:13  <br/>
 * Description: 用户服务实现类
 */

@Service
public class PetOwnerServiceImpl extends ServiceImpl<PetOwnerMapper, PetOwner> implements PetOwnerService {

    @Autowired
    private PetOwnerMapper petOwnerMapper;

    /**
     * Description : 根据宠物主人ID联查用户id，从而获取宠物主人完整信息
     * ChangeLog : 1. 创建 (2025/10/29 11:11 [Lenovo]);
     * @auther: 谢宝辉
     * date: 2025/10/29:11:11
     * @param ownerId
     * @return com.Cychat.commons.entity.pojo.PetOwner
    */
    @Override
    public PetOwner getPetOwnerById(int ownerId) {
        LambdaQueryWrapper<PetOwner> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PetOwner::getOwnerId, ownerId);
        return getOne(queryWrapper);
    }

    /**
     * Description : 根据用户ID查询宠物主人ID
     * ChangeLog : 1. 创建 (2025/10/29 17:48 [Lenovo]);
     * @auther: 谢宝辉
     * date: 2025/10/29:17:48
     * @param userId
     * @return java.lang.Integer
    */

    @Override
    public Integer getPetOwnerIdByUserId(Long userId) {
        return petOwnerMapper.getPetOwnerIdByUserId(userId);
    }
}